package com.zgm.ch04._4_1;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;

import com.zgm.ch04._4_1.interfaces.DemoBean;

public class BeanFactoryAwareLookupDemoBean implements DemoBean, BeanFactoryAware {
	private BeanFactory beanFactory;
	
	public MyHelper getMyHelper() {
		return (MyHelper) this.beanFactory.getBean("myHelper");
	}

	public void someOperation() {
		this.getMyHelper().doSomethingHelpful();
	}

	public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
		this.beanFactory = beanFactory;
	}

}
